#### ESTIMATION CONFIG ####
pars <- list()

# Things we frequently change
pars$EST_YEARS      <- 2010:2017

# Output name
pars$filename = 'estimation_final'

# Parallelization
pars$CORES <- 30

# Bootstrapping
pars$BOOTSTRAP_SIZE = .1
pars$BOOTSTRAP_N    = 10


# Initial guess              alpha|  beta|gamma| log_f
pars$initial_guess = c(              4.9,       13.0, # mu
                              0.6, -1.8,-3.8, 0.38, # pi_income
                              -0.5, 0.6, 2.30, 0.35, # pi_price
                              0.07,  1.3, 0.05, 0.69) # sigma

# Moment weights
pars$moment_weights <- rbind(
  data.table(moment = 'xi_var'                             , weight = 3.196960e-05),
  data.table(moment = 'xi_income_covar'                    , weight = 4.078403e+01),
  data.table(moment = 'xi_price_covar'                     , weight = 2.756062e+01),
  data.table(moment = 'bunching_mean'                      , weight = 8.342277e+04 * 1e2),
  data.table(moment = 'just_above_mean'                    , weight = 9.342277e+05 * 1e1),
  data.table(moment = 'just_below_mean'                    , weight = 8.342277e+05 * 1e1),
  data.table(moment = 'bunching_distance'                  , weight = 3.833751e+05 * 1e1),
  data.table(moment = 'bunching_income_relationship'       , weight = 2.722720e+04 * 1e1),
  data.table(moment = 'bunching_price_relationship'        , weight = 1.471841e+04 * 1e1),
  data.table(moment = 'bunching_q1'                        , weight = 8e+06        * 1e2),
  data.table(moment = 'bunching_q2'                        , weight = 6e+06        * 1e2),
  data.table(moment = 'bunching_q3'                        , weight = 4e+06        * 1e2),
  data.table(moment = 'bunching_q4'                        , weight = 1e+06        * 1e2),
  data.table(moment = 'income_bunching_mean'               , weight = 1.264193e-09),
  data.table(moment = 'income_bunching_distance'           , weight = 5.991521e-20),
  data.table(moment = 'income_bunching_income_relationship', weight = 2.748454e-06),
  data.table(moment = 'income_bunching_price_relationship' , weight = 9.968332e-07),
  data.table(moment = 'mean_loan_size_mean'                , weight = 1.711361e+01 * 1e2),
  data.table(moment = 'mean_loan_size_distance'            , weight = 2.796861e+03 * 1e1),
  data.table(moment = 'mean_loan_size_income_relationship' , weight = 3.279791e+03 * 1e-1),
  data.table(moment = 'mean_loan_size_price_relationship'  , weight = 8.173889e+05 * 1e-1),
  data.table(moment = 'std_loan_size_mean'                 , weight = 1.482293e+03 * 1e1),
  data.table(moment = 'std_loan_size_distance'             , weight = 2.737355e+05),
  data.table(moment = 'std_loan_size_income_relationship'  , weight = 1.512040e+06 * 1e-1),
  data.table(moment = 'std_loan_size_price_relationship'   , weight = 3.031373e+05 * 1e-1),
  data.table(moment = 'convergence.pct'                    , weight = 1.000000e+00 * 1e5))


## Things mostly kept constant
pars$N_SIM          <- 2500
pars$BLP_TOL        <- 1e-7
pars$BLP_ATTEMPTS   <- 500
pars$SEED           <- as.numeric(Sys.time())
pars$LTV_LIMIT      <- 0.90 
pars$BUNCHING_DELTA <- 0.005




# Diagnostic output
pars$diag.show_moments     <- T
pars$diag.show_linear      <- T
pars$diag.show_parameters  <- T
pars$diag.show_convergence <- T
pars$DEV                   <- F

